<?php
session_start();
class Artice extends CI_Controller{
    function  __construct(){
        parent::__construct();
        $this->load->library(array('form_validation','session','user_libs','artice_libs'));
        $this->load->library('ckeditor',array('instanceName' => 'addartice','basePath' => base_url()."ckeditor/", 'outPut' => true));
        $this->load->helper(array( 'url','form'));
        if(!$this->user_libs->isLogin() || !$this->user_libs->isAdmin()){
            redirect(base_url().'backend/login');
            exit();
        }
    }
    function index(){
        
        redirect(base_url().'backend/artice/listartice');
    }
    function listartice(){
        
    }
    function addartice(){
        $_SESSION['KCFINDER'] = array();
        $_SESSION['KCFINDER']['disabled'] = false;
        $articePost = $this->artice_libs->getPost(); // kiem tra co du lieu truyen vao hay khong
        if (!$articePost){
            $data['articeContent'] = 'Bai viet demo';
        } else { // $articePost la mot mang cac gia tri duoc truyen vao
            $dataInsert['articeTitle'] = $articePost['articeTitle'];
            $data['articeContent'] = $this->artice_libs->makeHtml($articePost['articeContent']);
            //$articeInsert = $this->artice_model->addArtice($dataInsert);
            $data = $articePost;
        }
        $data['page'] = 'backend/artice/addartice';
        $this->load->view('backend/temp', $data);
        
    }
    function editartice(){
        if ( isset( $_POST ) )
        	$postArray = &$_POST ;			// 4.1.0 or later, use $_POST
        else
        	$postArray = &$HTTP_POST_VARS ;	// prior to 4.1.0, use HTTP_POST_VARS

        
        $data['articeedit'] = @$postArray['articeedit'];
        $data['page'] = 'backend/artice/editartice';
        $this->load->view('backend/temp', $data);
    }
    function delartice(){
        
    }
}